﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketModel;
using AppSocketService.AlarmHistory;
using BCGPSCommon;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.AlarmHistory.Company
{
    /// <summary>
    /// 报警历史记录
    /// </summary>
    [ApiExplorerSettings(GroupName = "CompanyPage")]
    [Route("api/[controller]")]
    [ApiController]
    public class AlarmHistoryCompanyController : PageBaseController
    {
        private readonly IAlarmNotifyHistoryService alarmNotifyHistoryService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="alarmNotifyHistoryService"></param>
        public AlarmHistoryCompanyController(IAlarmNotifyHistoryService alarmNotifyHistoryService)
        {
            this.alarmNotifyHistoryService = alarmNotifyHistoryService;
        }

        /// <summary>
        /// 查询报警记录 -- 分页
        /// </summary>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="account_id">账户Id</param> 
        /// <param name="imei">IMEI</param>
        /// <param name="alarm_type">报警类型</param>
        /// <param name="notify_type">报警通知类型</param> 
        /// <param name="is_confirm">是否已确认</param>
        /// <param name="is_delete">是否已删除</param>
        /// <param name="desc">倒序</param>
        /// <param name="index" >页码</param>
        /// <param name="size">记录数</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<AlarmNotifyHistoryDto>), 200)]
        public ActionResult<PageableList<AlarmNotifyHistoryDto>> QueryPage(DateTime ?start, DateTime ?end, string account_id, string imei, AlarmType? alarm_type, AlarmNotifyType? notify_type, bool? is_confirm, bool? is_delete = false, bool? desc = false,int? index = 0,int? size=20)
        { 
            return alarmNotifyHistoryService.GetListCompany(start,end,account_id, imei, alarm_type, notify_type, is_confirm,is_delete.Value,desc.Value,index.Value,size.Value);
        }

        /// <summary>
        /// 报警确认
        /// </summary>
        /// <param name="id">报警记录Id</param>
        /// <returns></returns>
        [HttpPut("[action]")]
        [ProducesResponseType(typeof(OkResult), 200)]
        public ActionResult AlarmConfirm(string id)
        {
            alarmNotifyHistoryService.AlarmConfirm(id);
            return new OkResult();
        }

        /// <summary>
        /// 批量报警确认
        /// </summary>
        /// <param name="id_list">报警记录列表Id</param>
        /// <returns></returns>
        [HttpPut("[action]")]
        [ProducesResponseType(typeof(OkResult), 200)]
        public ActionResult AlarmListConfirm(List<string> id_list)
        {
            alarmNotifyHistoryService.AlarmConfirm(id_list);
            return new OkResult();
        }
    }
}